<?php
error_reporting(0);
include 'check.php';
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
BODY{
font-size:12px;
}
-->
</style>

<SCRIPT language=javascript>
function check() 
{
	var strFileName=document.form1.up_pic.value;
	if (strFileName=="")
	{
    	alert("请选择要上传的文件");
		document.form1.FileName.focus();
    	return false;
  	}
	var strRegex = "(.jpg|.gif|.png)$"; //用于验证图片扩展名的正则表达式
	var re=new RegExp(strRegex);
	if (re.test(strFileName.toLowerCase())){
		return true;
	}
	else{
		alert("文件名不合法,文件的扩展名必须为jpg,gif,png格式"); 
		return false;
	}
}
</SCRIPT>
</head>
<body leftmargin="0" topmargin="0">
<?php
if($_GET["pic"]==""){
?>
<form action="saveuppic.php" method="post" name="form1"  enctype="multipart/form-data">
  <input name="up_pic" type="file" id="up_pic" size="20" onChange="return check()">
  <input name="vp" type="hidden" id="vp" value="1">
  <input type="submit" name="Submit" value="上传">
</form>
<?php
}
else
{
	echo "<table style='margin-top:8px;'>图片已经上传，<a href=\"../upload/".$_GET["pic"]."\" target=_blank>查看</a> <a href=uppic.php>重新上传</a>！</table>";
}?>
</body>
</html>


